package ihm;

import ihm.Executable;
import contracts.*;
import services.*;
import ihm.TerrainJeu;
import impl.MoteurJeuImpl;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;


public class Executable extends JFrame{

	private static final long serialVersionUID = 1L;
	public Executable() throws ContractException{
		MoteurJeuService jeu = new MoteurJeuContract(new MoteurJeuImpl());
		JLabel label = new JLabel("Score");
		setLayout(new BorderLayout());
		add(label,BorderLayout.NORTH);
		jeu.init(30);
	/*	Sound sound = new Sound("");
		InputStream stream = new ByteArrayInputStream(sound.getSamples());
		sound.play(stream);
		
	*/	TerrainJeu p = new TerrainJeu(jeu, label);
		
		new Jeu(jeu,p).start();
		this.add(p,BorderLayout.CENTER);
		
		setPreferredSize(new Dimension(jeu.getTerrain().getNombreColonnes()*50,jeu.getTerrain().getNombreLignes()*50));
		setVisible(true);
		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		setResizable(true);
		
		pack();
	}
	
	public static void main(String[] args) {
		try {
			new Executable();
		} catch (ContractException e) {
			e.printStackTrace();
		}
	}

}